class Sample
  include Mongoid::Document
  include Mongoid::Timestamps
  
  default_scope ->{ desc(:created_at) }

  field :uuid, type: String
  field :path, type: String

  belongs_to :finger, counter_cache: true
  belongs_to :task

  def valid_sample?
    self.finger.valid_sample_ids.include?(self.id.to_s)
  end

  def image_path
    Rate::SAMPLE_ROOT + '/' + path
  end
end
